<?php

declare(strict_types=1);

namespace App\CustHub\Utils;

use App\CustHub\Mapper\ChOpenWorkAppMapper;
use App\Setting\Service\SettingConfigService;

class OpenWorkAppUtil
{
    public static function getSuiteIdAndSuiteSecret()
    {
        $authAppId = container()->get(SettingConfigService::class)->getConfigByKey('auth_app_id')['value'];
        $info = container()->get(ChOpenWorkAppMapper::class)->findById($authAppId);

        return [
            $info['suite_id'] ?? '',
            $info['suite_secret'] ?? ''
        ];
    }

    public static function getSuiteSecret()
    {
        $weWorkConfig = container()->get(SettingConfigService::class)->getConfigByGroupKey('open_work');
        $weWorkConfigGroup = array_column($weWorkConfig,'value','key');
        return $weWorkConfigGroup['suite_secret'] ?? '';
    }
}